home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 26
/
Cream of the Crop 26.iso
/
program
/
shrlk201.zip
/
_SETUP.1
/
Test.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
1997-07-22
|
5KB
|
168 lines
//---------------------------------------------------------------------------
#include <vcl\vcl.h>
#pragma hdrstop
#include "Test.h"
#include "Help.h"
//---------------------------------------------------------------------------
#pragma link "nsShareLock"
#pragma resource "*.dfm"
TfrmTester *frmTester;
//---------------------------------------------------------------------------
__fastcall TfrmTester::TfrmTester(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TfrmTester::mnuMain_Help_AboutClick(TObject *Sender)
{
frmAboutTester->ShowModal();
}
//---------------------------------------------------------------------------
void __fastcall TfrmTester::FormCreate(TObject *Sender)
{
Height = 82;
}
//---------------------------------------------------------------------------
void __fastcall TfrmTester::FormShow(TObject *Sender)
{
ShareLock->CheckProtection();
DoStatus();
}
//---------------------------------------------------------------------------
void __fastcall TfrmTester::sbtnStatusClick(TObject *Sender)
{
if (sbtnStatus->Down)
{
Height = 252;
sbtnStatus->Caption = "Status <<";
}
else
{
Height = 82;
sbtnStatus->Caption = "Status >>";
};
}
//---------------------------------------------------------------------------
void __fastcall TfrmTester::DoStatus()
{
lblTryOut->Caption = IntToStr(ShareLock->TryNumber);
lblProductName_Out->Caption = ShareLock->ProgramName;
lblDLLVersion_Out->Caption = ShareLock->DLLVersion;
switch (ShareLock->Protection) {
case ptRunCount:
{
lblProtectionType_Out->Caption = "Run Count";
if ((ShareLock->TrialPeriodRemaining <= 0) && (ShareLock->GracePeriod > 0)) lblDaysLeft_Out->Caption = IntToStr( ShareLock->TrialPeriodRemaining);
else lblDaysLeft_Out->Caption = IntToStr(ShareLock->TrialPeriodRemaining);
lblExpireDate_Out->Caption = "N/A";
lblGraceExpire_Out->Caption = "N/A";
lblDaysLeft->Caption = "Runs Left";
lblTrialLength_Out->Caption = IntToStr(ShareLock->TrialLength);
lblGracePeriod_Out->Caption = IntToStr(ShareLock->GracePeriod);
break;
}
case ptSpecificDate, ptNumberDays:
{
switch (ShareLock->Protection)
{
case ptSpecificDate:
{
lblProtectionType_Out->Caption = "Specific Date";
break;
}
case ptNumberDays:
{
lblProtectionType_Out->Caption = "Number Days";
break;
}
}
lblDaysLeft_Out->Caption = IntToStr(ShareLock->TrialPeriodRemaining);
lblDaysLeft->Caption = "Days Left";
lblExpireDate_Out->Caption = FormatDateTime("ddddd", ShareLock->ExpirationDate);
lblGraceExpire_Out->Caption = FormatDateTime("ddddd", ShareLock->ExpirationDate + ShareLock->GracePeriod);
lblTrialLength_Out->Caption = IntToStr(ShareLock->TrialLength);
lblGracePeriod_Out->Caption = IntToStr(ShareLock->GracePeriod);
break;
}
case ptNoExpire:
{
lblProtectionType_Out->Caption = "No Expire";
lblExpireDate_Out->Caption = "N/A";
lblGraceExpire_Out->Caption = "N/A";
lblTrialLength_Out->Caption = "N/A";
lblGracePeriod_Out->Caption = "N/A";
lblDaysLeft_Out->Caption = "N/A";
break;
}
}
switch (ShareLock->Status)
{
case stTrialPeriod:
{
lblStatus_Out->Caption = "Trial Period";
break;
}
case stRegistered:
{
lblStatus_Out->Caption = "Registered";
break;
}
case stGracePeriod:
{
lblStatus_Out->Caption = "Grace Period";
break;
}
case stExpired:
{
lblStatus_Out->Caption = "Expired";
break;
}
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmTester::mnuMain_Help_TestAboutClick(TObject *Sender)
{
ShareLock->DisplayAboutDialog();
}
//---------------------------------------------------------------------------
void __fastcall TfrmTester::ShareLockSuggestTerminate(int Reason)
{
switch (Reason)
{
case 1: //Exceeded Tries
{
Application->Terminate();
break;
}
case 2: //CannotOpenRegistry
{
Application->Terminate();
break;
}
case 3: //Clock moved back
{
Application->Terminate();
break;
}
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmTester::mnuMain_Help_RegisterClick(TObject *Sender)
{
ShareLock->DisplayRegistrationDialog();
DoStatus();
}
//---------------------------------------------------------------------------
void __fastcall TfrmTester::mnuMain_File_ExitClick(TObject *Sender)
{
Close();
}
//---------------------------------------------------------------------------